<script language="javascript">
    $(document).ready(function() {
        $('#data_cliente').dataTable( {
            "bJQueryUI": true,
            "sPaginationType": "full_numbers",
            "oLanguage": {
                "sLengthMenu": "Mostrar _MENU_ clientes por pagina",
                "sZeroRecords": "Ningun cliente encontrado :(",
                "sInfo": "Mostrando _START_ a _END_ de _TOTAL_ clientes",
                "sInfoEmpty": "Mostrando 0 a 0 de 0 clientes",
                "sInfoFiltered": "(Filtrando de _MAX_ clientes)"
            }
        } );
    } );
</script>

<article class="module width_full">
    <header><h3>Lista de Tareas</h3></header>
    <div class="module_content">
        <article class="breadcrumbs_content">
            <a href="<?php echo $this->url(array('action' => 'addtarea', 'id'=>null)) ?>">Agregar Tarea</a>
        </article>

        <table cellpadding="0" cellspacing="0" border="0" class="display" id="data_cliente" width="100%">
            <thead>
                <tr>
                    <th>Titulo</th>
                    <th>Orden</th>
                    <th>Trabajo</th>
                    <th>Usuario</th>
                    <th>Estado</th>
                    <th>Acciones</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($this->result as $tarea) : ?>
                    <?php
                    $tu = new Tarea_Model_DbTable_TareaUser();
                    $resT = $tu->fetchAll('id_tarea=' . $tarea->tarea_id);
                    ?>
                    <tr>
                        <td><?php echo $tarea->title; ?></td>
                        <td><?php echo $tarea->code; ?></td>
                        <td><?php echo $tarea->name; ?></td>
                        <td>
                            <?php
                            $user = new User_Model_DbTable_User();
                            if ($resT != null) {
                                foreach ($resT as $us) {
                                    $dUser = $user->fetchRow('id=' . $us->id_user);
                                    echo $dUser->nombre . ' ' . $dUser->apellidos . ', ';
                                }
                            }
                            ?>
                        </td>
                        <td>
                            <?php
                            if ($tarea->status == 1)
                                echo "En progreso";
                            else
                                echo "Aprobado";
                            ?>
                        </td>
                        <td class="center">
                            <a href="<?php echo $this->url(array('action' => 'edit', 'id' => $tarea->tarea_id)) ?>" title="Editar Tarea">
                                <img src="<?php echo $this->baseUrl() ?>/public/styles/admin/images/icn_edit.png"/>
                            </a>
                            <span>&nbsp;&nbsp;&nbsp;</span>
                            <a onclick="return confirm ('Esta seguro que quiere eliminar esta tarea ?')" title="Eliminar Tarea" href="<?php echo $this->url(array('action' => 'delete', 'id' => $tarea->tarea_id)) ?>">
                                <img src="<?php echo $this->baseUrl() ?>/public/styles/admin/images/icn_trash.png"/>
                            </a>
                            <span>&nbsp;&nbsp;&nbsp;</span>
                            <a href="<?php echo $this->url(array('action' => 'viewtarea', 'id' => $tarea->tarea_id)) ?>" title="Detalle">
                                Ver
                            </a>
                        </td>
                    </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</article>